package com.sample.controller;

import com.sample.dto.CustomBody;
import org.springframework.http.ResponseEntity;

/**
 * Created by leo.na on 21/03/2017.
 */
public final class RestResponse {

    private RestResponse() {
    }

    /**
     * Create success response with message and data
     *
     * @param message message
     * @param data    body data
     */
    public static <T> ResponseEntity<CustomBody> ok(String message, T data) {
        return ResponseEntity.ok().body(new CustomBody<>(message, data));
    }

    /**
     * Create BAD_REQUEST response with message
     *
     * @param message message
     */
    public static ResponseEntity<CustomBody> badRequest(String message) {
        return ResponseEntity.badRequest().body(new CustomBody(message, null));
    }

}
